<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/style.css" />
		<script src="../js/head_public.js"></script>
	
	</head>
	<body>
		<header class="mui-bar mui-bar-nav ding-bar" >
			<div style="position: relative;">
				 <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			    <h1 class="mui-title">我的收获地址</h1>
			    <span class="add-address">+</span>
			</div>   
		</header>
		<div class="mui-content">
			<ul class="shdz-list">
				<!--<li>
					<p>
						<span class="name">王五</span>
						<span class="phone">18139186350</span>
						<img class="del" src="../images/ad-del.png" />
						<img class="xiugai"src="../images/ad-xiugai.png" />
					</p>
					<p class="mr-ad"><span>[默认]</span>甘肃省兰州市七里河区兰驼小区武山路50号</p>
				</li>
				<li>
					<p>
						<span class="name">王五</span>
						<span class="phone">18139186350</span>
						<img class="del" src="../images/ad-del.png" />
						<img class="xiugai"src="../images/ad-xiugai.png" />
					</p>
					<p class="mr-ad"><span>[默认]</span>甘肃省兰州市七里河区兰驼小区武山路50号</p>
				</li>
				<li>
					<p>
						<span class="name">王五</span>
						<span class="phone">18139186350</span>
						<img class="del" src="../images/ad-del.png" />
						<img class="xiugai"src="../images/ad-xiugai.png" />
					</p>
					<p class="mr-ad"><span>[默认]</span>甘肃省兰州市七里河区兰驼小区武山路50号</p>
				</li>
				<li>
					<p>
						<span class="name">王五</span>
						<span class="phone">18139186350</span>
						<img class="del" src="../images/ad-del.png" />
						<img class="xiugai"src="../images/ad-xiugai.png" />
					</p>
					<p class="mr-ad"><span>[默认]</span>甘肃省兰州市七里河区兰驼小区武山路50号</p>
				</li>
				<li>
					<p>
						<span class="name">王五</span>
						<span class="phone">18139186350</span>
						<img class="del" src="../images/ad-del.png" />
						<img class="xiugai"src="../images/ad-xiugai.png" />
					</p>
					<p class="mr-ad"><span>[默认]</span>甘肃省兰州市七里河区兰驼小区武山路50号</p>
				</li>
				<li>
					<p>
						<span class="name">王五</span>
						<span class="phone">18139186350</span>
						<img class="del" src="../images/ad-del.png" />
						<img class="xiugai"src="../images/ad-xiugai.png" />
					</p>
					<p class="mr-ad"><span>[默认]</span>甘肃省兰州市七里河区兰驼小区武山路50号</p>
				</li>-->
			</ul>
		</div>	
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery-1.8.0.min.js"></script>
		<script src="../js/common.js"></script>
		<script src="../js/session.js"></script>
		<script>
			
			var pay=getQueryString("pay");
			var userid=getCookie("userid");
			var ye=getQueryString("ye");
			mui("header").on("tap",".add-address",function(){
				if(pay!=null){
					location.href="add-address.html?pay="+pay+"&ye="+ye
				}else{
					location.href="add-address.html"
				}
				
			})
			if(userid==""||userid==null){
				alert("您还没有登录，请先登录")
				location.href="../public/login.html"
			}else{
				var params={};
				params.member_id=userid;
				
				$.post(net+"/public/index.php?s=api/Memberorder/address	",params,function(res){
					if(res.code=="201"){
						alert("您还没有收货地址，请前去添加")
						if(pay!=null){
							location.href="add-address.html?pay="+pay+"&ye="+ye
						}else{
							location.href="add-address.html"
						}
						
					}else if(res.code=="200"){
						var str="";
						if(res.result!=null&&res.result.length!=0){
							$.each(res.result, function(index,val) {
								var adress=''
								if(this.address_is_default=="1"){
									adress='<span>[默认]</span>'+this.area_name+this.city_name+this.zone_name+this.address_detail
								}else{
									adress=this.area_name+this.city_name+this.zone_name+this.address_detail
								}
								str+='<li><p><span class="name">'+this.address_realname+'</span><span class="phone">'+this.address_mob_phone+'</span><img class="del" data-id="'+this.address_id+'" src="../images/ad-del.png" /><img class="xiugai" src="../images/ad-xiugai.png" data-id="'+this.address_id+'"/></p><p class="mr-ad">'+adress+'</p></li>'
							});
						}else{
							alert("您还没有收货地址，请前去添加")
							if(pay!=null){
								location.href="add-address.html?pay="+pay
							}else{
								location.href="add-address.html"
							}
						}
						
						$(".shdz-list").append(str);
					}
				})
				mui(".shdz-list").on("tap",".del",function(){
					var id=$(this).attr("data-id");
					if(id!=null&&id!=null){
						var param={};
						param.member_id=userid;
						param.address_id=id;
						$.post(net+"/public/index.php?s=api/Memberorder/del_address",param,function(res){
							if(res.code=="200"){
								alert("删除成功")
								location.reload()
							}
						})
					}
				})
				mui(".shdz-list").on("tap",".xiugai",function(){
					var id=$(this).attr("data-id");
					
					if(pay!=null){
						location.href="add-address.html?pay="+pay+"&id="+id+"&ye="+ye;
					}else{
						location.href="add-address.html?id="+id;
					}
				})
			}
		</script>
	</body>

</html>